#ifndef __WIZ_UTILS_RANDOM_CORE_HPP__SHANHAOBO_19800429__
#define __WIZ_UTILS_RANDOM_CORE_HPP__SHANHAOBO_19800429__

#include "../../Base/WizBase.hpp"

namespace Wiz
{
    namespace Random
    {
        namespace Core
		{
			namespace NonRange
			{
				template<class EngineT, class NumT>
				class Type
				{
					typedef NumT					tNum;
					typedef const tNum&				tNumIn;
					typedef EngineT					tEngine;
					typedef typename tEngine::tNum	tEngineNum;
					typedef const tEngine&			tEngineIn;
				public:
					tNum Generate(tEngineIn Eng) const
					{
						return ::Wiz::Cast::Static<tNum>(Eng.Rand());
					}
				public:
					Type()
					{
					}
				};
			} /// end of namespace NonRange

			namespace Range
			{
				template<class EngineT, class NumT>
				class Type
				{
					typedef EngineT					tEngine;
					typedef const tEngine&			tEngineIn;
					typedef typename tEngine::tNum	tEngineNum;
					typedef const tEngineNum&		tEngineNumIn;
					typedef NumT					tNum;
					typedef const tNum&				tNumIn;
				private:
					tNum					m_Min;
					tNum					m_Max;
					::Wiz::Real64::Type		m_RangeScale;
				private:
					WIZ_INLINE tNum GetMin() const
					{
						return m_Min;
					}
					WIZ_INLINE tNum GetMax() const
					{
						return m_Max;
					}
					WIZ_INLINE tNum GetRange() const
					{
						return GetMax() - GetMin();
					}
				public:
					tNum Generate(tEngineIn Eng) const
					{
						const tEngineNum RandVal = Eng.Rand() - Eng.GetMin();

						return ::Wiz::Cast::Static<tNum>(RandVal * m_RangeScale + this->GetMin());
					}
				public:
					Type()
					{
					}
				public:
					::Wiz::Void::Type SetMinMax(tEngineNumIn EngRange, tNumIn Min, tNumIn Max)
					{
						m_Min = Min;
						m_Max = Max;

						m_RangeScale	= ::Wiz::Cast::Static<::Wiz::Real64::Type>(this->GetRange()) / ::Wiz::Cast::Static<::Wiz::Real64::Type>(EngRange);
					}
				};
			} /// end of namespace Range
		} /// end of namespace Core
    } /// end of namespace Random
} /// end of namespace Engine

#endif /*__WIZ_UTILS_RANDOM_CORE_HPP__SHANHAOBO_19800429__*/
